# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id: libratbox-3.0.6.ebuild 197 2011-10-19 03:13:03Z dubkat $

EAPI=3

SRC="ircd-ratbox"
LEVEL="testing"

MY_PN=${PN//-tools}
MY_PV=${PV/_p/-P}
MY_PV=${MY_PV/_rc/rc}
MY_P="${MY_PN}-${MY_PV}"


DESCRIPTION="ircd-ratbox is an advanced, stable and fast ircd. (libs)"
HOMEPAGE="http://www.ratbox.org"
SRC_URI="http://www.ratbox.org/download/ircd-ratbox-${PV}.tar.bz2"

if [ "$LEVEL" = "testing" ]; then
	SRC_URI="http://www.ratbox.org/download/testing/ircd-ratbox-${PV}.tar.bz2"
fi


RESTRICT="primaryuri"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS=""
IUSE="pic profile debug gnutls ssl ipv6 static services"

DEPEND="
	virtual/yacc
	sys-libs/zlib
	ssl? ( dev-libs/openssl )
	gnutls? ( net-libs/gnutls )
"

RDEPEND="${DEPEND}"

MY_WORKDIR="${WORKDIR}/${SRC}-${MY_PV}"

S="${MY_WORKDIR}/${MY_PN}"

src_unpack() {
	unpack ${A}
}

src_configure() {

	if use ssl && use gnutls; then
		ewarn "You have USE flags 'ssl' and 'gnutls' both enabled."
		ewarn "By default, libratbox will use only openssl."
	fi

	my_flags="--disable-option-checking";
	if use debug; then my_flags="$my_flags --enable-assert=soft"; fi

	econf \
		$my_flags \
		$(use_enable ipv6) \
		$(use_enable services) \
		$(use_enable static) \
		$(use_enable ssl openssl) \
		$(use_enable gnutls) \
		$(use_with pic) \
		$(use_enable profile) \
	|| die "econf failed."
}

src_compile() {
	emake || die "emake failed."
}

src_install() {
	einstall || dir "einstall failed."
}

